<template>
  <view>
    <view class="loadingClass"
      >拼命加载中...
      <u-loading mode="circle"></u-loading>
    </view>
  </view>
</template>

<script setup>
import { useMemberStore } from "@/stores/modules/member";
import { get_user_info } from "./index";
import { baseURL } from "@/utils";
const memberStore = useMemberStore();

const scanLogin = () => {
  dd.getAuthCode({
    success: (res) => {
      dd.httpRequest({
        headers: {
          "Content-Type": "application/json",
        },
        url: `${baseURL}/ding_ding_login?authCode=${res.authCode}`,
        method: "POST",
        dataType: "json",
        timeout: 30000,
        success: async (result) => {
          const res = result.data;
          if (res?.code == 200) {
            memberStore.token = res.data.tokenInfo.token;
            memberStore.userId = res.data.userId;
            memberStore.userName = res.data.userName;
            memberStore.deptMap = Object.values(res.data.deptMap);
            const respose = await get_user_info();
            memberStore.userInfo = respose.data;
            uni.switchTab({
              url: "/pages/index/index",
            });
          }
        },
      });
    },
  });
};
onShow(() => {
  scanLogin();
});
</script>

<style lang="scss" scoped>
</style>
